<?PHP
include("/home/eliwww/lib/lib_eliremote.php");

$email = $_GET["email"];
$email = str_replace(" ","",trim($email),$i);

$result ;
$res ;

$db = new mydb;
$db -> conn2db_eliremote();
$db -> do_select_db( "eliremote" );

if($email)
{
	$qry = "select	onl_server,max_server from user_info where email = '".$email."'";

	if( $db -> do_query( $qry, $res ) )
	{
		$result = "E";
		raise_error( __FILE__, __LINE__, $db );
	}
	else
	{
		$row = $db -> do_fetch_one( $res );
		$onl = (int)$row['onl_server'];
		$max = (int)$row['max_server'];
		//echo $onl;echo "<br>";
		//echo $max;echo "<br>";

		if($onl >= 0 && $max >= 0)
		{
			if($max > $onl)
			{
				//echo "vao1";echo "<br>";
				$onl += 1;
				$qry = "update user_info set onl_server=" .$onl. " where email = '".$email."'";

				if( $db -> do_query( $qry, $res ) )
				{
					$result = "E";
					raise_error( __FILE__, __LINE__, $db );
				}
				else
				{
					$result = "Y";
				}
			}
			else
			{
				//echo "vao2";echo "<br>";
				$result = "N";
			}			
		}
		else
		{
			//echo "vao3";echo "<br>";		
			$result = "N";
		}
	}		
	
}
else
{
	$result = "P";
}

$db -> do_close();
echo $result;


?>